from datetime import datetime


class TimeUtils:

    @staticmethod
    def to_yymmdd_str(time: datetime,num_str = "无"):
        if time is None:
            return num_str
        return time.strftime("%Y-%m-%d")

    @staticmethod
    def split_datetime(time: datetime):
        """
        将time分离成：yy_mm_dd, SS_MM_SS 方式。
        """
        return int(time.year * 10000 + time.month * 100 + time.day), int(
            time.hour * 10000 + time.minute * 100 + time.second)

    @staticmethod
    def to_yy_MM_dd_hh_mm(time: datetime):
        """
        将time分离成：yy_mm_dd, SS_MM_SS 方式。
        """
        return int(time.year * 100 * 100 * 100 * 100 + time.month * 100 * 100* 100 + time.day * 100 * 100 + time.hour * 100 + time.minute)

    @staticmethod
    def merge_datetime(year_month_day: int, hour_mintue_second: int):
        year = int(year_month_day / 10000 + 0.01)
        month = int((year_month_day / 100) % 100 + 0.01)
        day = int(year_month_day % 100 + 0.01)
        hour = int(hour_mintue_second / 10000 + 0.01)
        minute = int((hour_mintue_second / 100) % 100 + 0.01)
        second = int(hour_mintue_second % 100 + 0.01)
        return datetime(year=year, month=month, day=day, hour=hour, minute=minute, second=second)